package com.ruoyi.project.bajiaostar.tGoodOrder.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.bajiaostar.tGoodOrder.domain.TGoodOrder;
import com.ruoyi.project.bajiaostar.tGoodOrder.service.ITGoodOrderService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 商品详情信息Controller
 * 
 * @author wangwu
 * @date 2024-05-21
 */
@Controller
@RequestMapping("/bajiaostar/tGoodOrder")
public class TGoodOrderController extends BaseController
{
    private String prefix = "bajiaostar/tGoodOrder";

    @Autowired
    private ITGoodOrderService tGoodOrderService;

    @RequiresPermissions("bajiaostar:tGoodOrder:view")
    @GetMapping()
    public String tGoodOrder()
    {
        return prefix + "/tGoodOrder";
    }

    /**
     * 查询商品详情信息列表
     */
    @RequiresPermissions("bajiaostar:tGoodOrder:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGoodOrder tGoodOrder)
    {
        startPage();
        List<TGoodOrder> list = tGoodOrderService.selectTGoodOrderList(tGoodOrder);
        return getDataTable(list);
    }

    /**
     * 导出商品详情信息列表
     */
    @RequiresPermissions("bajiaostar:tGoodOrder:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGoodOrder tGoodOrder)
    {
        List<TGoodOrder> list = tGoodOrderService.selectTGoodOrderList(tGoodOrder);
        ExcelUtil<TGoodOrder> util = new ExcelUtil<TGoodOrder>(TGoodOrder.class);
        return util.exportExcel(list, "tGoodOrder",null);
    }

    /**
     * 新增商品详情信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存商品详情信息
     */
    @RequiresPermissions("bajiaostar:tGoodOrder:add")
    @Log(title = "商品详情信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TGoodOrder tGoodOrder)
    {
        return toAjax(tGoodOrderService.insertTGoodOrder(tGoodOrder));
    }

    /**
     * 修改商品详情信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TGoodOrder tGoodOrder = tGoodOrderService.selectTGoodOrderById(id);
        mmap.put("tGoodOrder", tGoodOrder);
        return prefix + "/edit";
    }

    /**
     * 修改保存商品详情信息
     */
    @RequiresPermissions("bajiaostar:tGoodOrder:edit")
    @Log(title = "商品详情信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TGoodOrder tGoodOrder)
    {
        return toAjax(tGoodOrderService.updateTGoodOrder(tGoodOrder));
    }

    /**
     * 删除商品详情信息
     */
    @RequiresPermissions("bajiaostar:tGoodOrder:remove")
    @Log(title = "商品详情信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tGoodOrderService.deleteTGoodOrderByIds(ids));
    }
}
